Skip to content

Report frontend dist size and soft budget on every build - #2215

Merged
David Pine (IEvangelist) merged 2 commits into
mainfrom
dapine-microsoft-dist-size-budget-ci
Nov 20, 2026
Merged

David Pine (IEvangelist) merged 2 commits into
mainfrom
dapine-microsoft-dist-size-budget-ci

Conversation

@IEvangelist

Copy link
Copy Markdown
Member

Summary

Part of a series to cut the size of the frontend container image (StaticHost + dist, currently ~9.8 GB of dist). Sibling PRs: dropping English fallback copies in locale folders, slimming the C# API reference sidebar, and moving repeated inline SVG/script/CSS to shared assets. This PR adds the guardrail that tracks progress and catches regressions.

  • src/frontend/scripts/measure-build-output.mjs
    • Reports total and HTML bytes, file and HTML page counts, median HTML page size, top-level directory sizes (including each locale folder), and reference/api sizes by language.
    • Writes a "Frontend dist size" table to the job summary.
    • Walks directories concurrently; a fake dist with 80k files took ~1.9 s locally.
    • The file manifest and compression sample are still only written for profile_build runs.
  • .github/workflows/frontend-build.yml: "Measure frontend output" now runs on every build where dist/index.html exists, not only for profile_build runs.
  • Soft size budget:
    • Over budget, the build gets a ::warning annotation. The default is 10 GiB, just above the current baseline, so it doesn't fire yet.
    • The repo variable FRONTEND_DIST_BUDGET_BYTES overrides the default.
    • Setting the repo variable FRONTEND_DIST_BUDGET_MODE=error turns the warning into a build failure.
    • In error mode the measure step fails before the StaticHost wait/upload steps; the site archive pack/upload still runs because it's always().

Third-party links and affiliations

None

Validation

  • vitest run tests/unit/build-performance.vitest.test.ts (standalone vitest 4.1.11, because bun isn't installed locally): passed, 11/11 tests (3 new, 1 updated).
  • node scripts/measure-build-output.mjs against a fake dist with 80,007 files: passed. It measured them in ~1.9 s, exited 0 in the default mode, printed a ::warning and exited 0 with DIST_SIZE_BUDGET_BYTES=1000, and printed a ::error and exited 1 with DIST_SIZE_BUDGET_MODE=error.
  • bun run build was not run locally; CI will produce the first real numbers.

Measure dist (total/HTML bytes, file and page counts, median page, top-level
and reference/api directories) in every frontend build, write it to the job
summary, and warn when it exceeds FRONTEND_DIST_BUDGET_BYTES (default 10 GiB).
Set FRONTEND_DIST_BUDGET_MODE=error to fail instead. The file manifest and
compression sample remain opt-in profiling diagnostics.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Frontend HTML artifact ready

The latest frontend build uploaded the frontend-dist artifact for PR #2215. Use the VS Code button below to open this PR with GitHub Artifacts Explorer and browse the built HTML locally.

VS Code: Open PR #2215 artifacts

This comment updates automatically when a new frontend build artifact is uploaded.

@IEvangelist

Copy link
Copy Markdown
Member Author

Combined validation: real aspire publish image

I merged #2215, #2214, #2213 and #2216 into the ADO deploy branch locally, then ran the same steps as pipelines/build.yml: bicep restore followed by aspire publish -o .generated (the Ev2 publish step). The resulting image was loaded with docker load and run as a container in Production mode with Redis.

Before After all four PRs
Ev2ServiceArtifactsRoot/Images/aspiredev.tar.gz ~4 GB 1.76 GB
Built HTML pages 38,344 29,134
Site output (dist) 9.8 GB 3.73 GB
wwwroot in image n/a 3.73 GB originals + 0.68 GB .br

The container starts in 11 s, /healthz returns 200, and idle memory is about 2 GB, likely from the 134 MB staticwebassets.endpoints.json.

Testing against the container

  • Layout check: 35 representative layouts (docs, splash, hub, 404, /de/ fallback, /ja/ translated, C#/TS/Go API landing, package, type and member pages) on desktop and mobile. Every page returned the expected status, with no failed requests and no page errors.
  • Full Playwright suite, CI=1 bunx playwright test, all 3 projects, reusing the container on :4322: 1,632 passed, 5 failed, 2 flaky, 107 skipped. Failures are triaged below.
  • Manual testing of the running container found no issues.
    This PR: on its own it doesn't change the size; it adds the per-build size report. The 9.8 GB to 3.73 GB dist drop above is what this report will show in CI once the others merge.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@IEvangelist
David Pine (IEvangelist) marked this pull request as ready for review November 20, 2026 18:08
Copilot AI balanced review requested due to automatic review settings November 20, 2026 18:08
@IEvangelist
David Pine (IEvangelist) merged commit 2e19a08 into main Nov 20, 2026
20 checks passed
@IEvangelist
David Pine (IEvangelist) deleted the dapine-microsoft-dist-size-budget-ci branch November 20, 2026 18:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the frontend build-size reporting and configurable budget changes.

No open issues 🎉

What changed in this PR

Adds frontend build-size reporting and a configurable budget to track progress toward smaller container images and flag output-size regressions.

Changes:

  • Reports total and HTML sizes, file counts, median HTML page size, and directory breakdowns in the job summary.
  • Runs measurement whenever build output is available, with a default 10 GiB warning budget and optional failure mode controlled by repository variables.
  • Keeps file manifests and compression samples profiling-only, and adds tests for reporting, budget behavior, and workflow configuration.
File Description
src/​frontend/​tests/​unit/​build-performance.vitest.test.ts Adds coverage for size reports, budget defaults and enforcement, and measurement-step configuration.
src/​frontend/​scripts/​measure-build-output.mjs Adds concurrent measurement, detailed summaries, and configurable budget checks.
.github/​workflows/​frontend-build.yml Enables measurement when output exists and passes repository budget settings.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants